package com.jt.controller;

import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("/findAll")
    public  String  findAll(Model model){
        List<User> userList = userService.findAll();
        model.addAttribute("userList",userList);
        return "userList";
    }
    @RequestMapping("/toAjax")
    public String toAjax(){
        return "ajax";
    }
    @RequestMapping("/ajaxUser")
    @ResponseBody
    public List<User> ajaxUser(Integer id,String name){
        System.out.println("id参数是"+id);
        System.out.println("name参数是"+name);
     return userService.findAll();
    }
}
